package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/itemCat")
public class ItemCatController {
    @Autowired
    private ItemCatService itemCatService;
    //获取三级商品分类列表
    @GetMapping("/findItemCatList/{level}")
    public SysResult findItemCatList(@PathVariable Integer level){
        List<ItemCat> list=itemCatService.findItemCatList(level);
        return SysResult.success(list);
    }
    //修改商品分类状态
    @PutMapping("/status/{id}/{status}")
    public SysResult updateItemCatStatus(@PathVariable Integer id,@PathVariable Boolean status){
        itemCatService.updateItemCatStatus(id,status);
        return SysResult.success();
    }
    //新增商品分类信息
    @PostMapping("/saveItemCat")
    public SysResult saveItemCat(@RequestBody ItemCat itemCat){
        itemCatService.saveItemCat(itemCat);
        return SysResult.success();
    }
    //修改商品分类信息
    @PutMapping("/updateItemCat")
    public SysResult updateItemCat(@RequestBody ItemCat itemCat){
        itemCatService.updateItemCat(itemCat);
        return SysResult.success();
    }
    //删除商品分类信息
    @DeleteMapping("/deleteItemCat")
    public SysResult deleteItemCat(Integer id,Integer level){
        itemCatService.deleteItemCat(id,level);
        return SysResult.success();
    }
}
